from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app


class MainPage(webapp.RequestHandler):
    """ Load Google's embeded graph to the Iframe """
    def get(self):
        self.response.out.write("""<script type="text/javascript" src="http://www.gmodules.com/ig/ifr?url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fgoogle_insightsforsearch_interestovertime_searchterms.xml&amp;up__property=empty&amp;up__search_terms=""")
        self.response.out.write(self.request.get('sQuery'));
        self.response.out.write("""%7C&amp;up__location=empty&amp;up__category=0&amp;up__time_range=3-m&amp;up__compare_to_category=false&amp;synd=ig&amp;w=400&amp;h=300&amp;lang=en-US&amp;title=Google+Insights+for+Search&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>""")


application = webapp.WSGIApplication(
                                     [('/showAnaly.html', MainPage)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()